<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/24/024
 * Time: 20:12
 */

namespace app\admin\validate;

class BannerValidate extends \think\Validate
{

    const SCENE_ADD = 'add'; //添加
    const SCENE_EDIT = 'edit'; //编辑
    const SCENE_REMOVE = 'remove'; //删除


    protected $rule = [
        'id' => 'require|number',
        'type_id' => 'require|number',
        'sort' => 'require|number',
        'title'  =>  'require|max:32',
        'title_en'  =>  'require|max:32',
        
    ];


    protected $message  = [
        'id.require' => 'ID必须',
        'id.number' => 'ID必须为数字',
        'type_id.require' => '类型必须',
        'type_id.number' => '类型必须为数字',
        'title.require' => '标题必须',
        'title.max' => '标题最长32',
        'title_en.require' => '副标题必须',
        'title_en.max' => '副标题最长32',
    ];
    
    //场景
    protected $scene  = [
       self::SCENE_ADD => ['type_id', 'title', 'title_en', 'sort'],
       self::SCENE_EDIT => ['id', 'type_id', 'title', 'title_en', 'sort'],
       self::SCENE_REMOVE => ['id'],
    ];
}